import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { EColor } from "../../../../../Message/Public/EColor";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { MountConfig } from "../../../resource/MountConfig";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { DataEvent } from "../../../events/DataEvent";
import { MountStartsEvents } from "../events/MountStartsEvents";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class MountStartsResultCellRender
    
    export  class MountStartsResultCellRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this._allData = new Object();
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._bm = ObjCreate.createBitmap("", 0, 0, this);
            LoaderHelp.addResCallBack(ResFileConst.mountStarts, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            this.changeBm();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1="";
            var loc2="";
            if (arg1) 
            {
                this._mountIData = arg1.mountIData;
                this._startsLv = arg1.lv;
                this._AttValue = arg1.AttValue;
                this._color = arg1.color;
                this._allData = arg1;
                if (this._loaded) 
                {
                    this.changeBm();
                }
                if (this._color >= EColor._EColorWhite && this._color <= EColor._EColorOrange) 
                {
                    loc1 = this._startsLv.toString() + "_" + this._color + "_" + this._AttValue;
                    loc2 = MountUtil.instance.getColorStr(this._color);
                    this.toolTipData = HTMLUtil.addColor(MountUtil.instance.getEjewelName(this._AttValue) + "+" + MountConfig.instance.getLvColorAtt2Value(loc1), loc2);
                }
                else 
                {
                    this.toolTipData = null;
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                this.filters = [FilterConst.gradientGlowFilter];
                this.dispatchEvent(new DataEvent(MountStartsEvents.ONRESULTCLICK, this._allData, false, true, false));
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal  */changeBm(): void
        {
            this.mouseChildren = true;
            this.mouseEnabled = true;
            this.useHandCursor = true;
            this.buttonMode = true;
            if (this._color != EColor._EColorWhite) 
            {
                if (this._color != EColor._EColorGreen) 
                {
                    if (this._color != EColor._EColorBlue) 
                    {
                        if (this._color != EColor._EColorPurple) 
                        {
                            if (this._color != EColor._EColorOrange) 
                            {
                                if (this._color != EColor._EColorRed) 
                                {
                                    this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsNoOpenStart);
                                    this.mouseChildren = false;
                                    this.mouseEnabled = false;
                                    this.useHandCursor = false;
                                    this.buttonMode = false;
                                }
                                else 
                                {
                                    this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsGoldStart);
                                }
                            }
                            else 
                            {
                                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsOrangeStart);
                            }
                        }
                        else 
                        {
                            this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsPurpleStart);
                        }
                    }
                    else 
                    {
                        this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsBuleStart);
                    }
                }
                else 
                {
                    this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsGreenStart);
                }
            }
            else 
            {
                this._bm.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountStartsWhiteStart);
            }
            return;
        }

        /* internal */ /* var */_bm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_mountIData: ItemData;

        /* internal */ /* var */_startsLv: int;

        /* internal */ /* var */_AttValue: int;

        /* internal */ /* var */_color: int;

        /* internal */ /* var */_loaded: Boolean;

        /* internal */ /* var */_allData: Object;
    }
